/**
 * 游戏状态管理服务
 * 负责初始化和管理游戏状态
 */

export default {
  /**
   * 创建初始游戏状态
   * @returns {Object} 初始游戏状态
   */
  createInitialState() {
    return {
      // 玩家数据
      players: [
        {
          id: 1,
          name: '玩家1',
          avatar: '/images/player1.svg',
          money: 1500,
          position: 0,
          properties: []
        },
        {
          id: 2,
          name: '玩家2',
          avatar: '/images/player2.svg',
          money: 1500,
          position: 0,
          properties: []
        },
        {
          id: 3,
          name: '玩家3',
          avatar: '/images/player3.svg',
          money: 1500,
          position: 0,
          properties: []
        }
      ],
      // 游戏状态
      currentPlayerIndex: 0,
      currentRound: 1,
      maxRounds: 30, // 最大回合数，防止游戏无限进行
      gameEnded: false,
      
      // 事件系统
      showEvent: false,
      currentEvent: {},
      
      // 棋盘数据
      boardCells: [],
      
      // 机会卡数据
      chanceCards: [],
      
      // 玩家移动队列和动画状态
      moveQueue: [],
      isMoving: false,
      moveSpeed: 300, // 移动速度(毫秒)
      
      // 特殊状态
      playerSpecialStatus: {
        1: { extraTurn: false, rentImmunity: false },
        2: { extraTurn: false, rentImmunity: false },
        3: { extraTurn: false, rentImmunity: false }
      }
    };
  },
  
  /**
   * 初始化棋盘数据
   * @returns {Array} 棋盘单元格数据
   */
  initBoardData() {
    return [
      { type: 'start', name: '起点', description: '经过或停留在此处获得200元' },
      { type: 'property', name: '东城区', price: 60, rent: 2, owner: null },
      { type: 'chance', name: '机会', description: '抽取一张机会卡' },
      { type: 'property', name: '西城区', price: 60, rent: 4, owner: null },
      { type: 'tax', name: '所得税', price: 200, description: '支付200元税款' },
      { type: 'transport', name: '北京站', price: 200, rent: 25, owner: null },
      { type: 'property', name: '朝阳区', price: 100, rent: 6, owner: null },
      { type: 'chance', name: '机会', description: '抽取一张机会卡' },
      { type: 'property', name: '海淀区', price: 100, rent: 6, owner: null },
      { type: 'property', name: '丰台区', price: 120, rent: 8, owner: null },
      { type: 'jail', name: '监狱', description: '仅仅是路过' },
      { type: 'property', name: '浦东新区', price: 140, rent: 10, owner: null },
      { type: 'utility', name: '电力公司', price: 150, rent: 15, owner: null },
      { type: 'property', name: '黄浦区', price: 140, rent: 10, owner: null },
      { type: 'property', name: '徐汇区', price: 160, rent: 12, owner: null },
      { type: 'transport', name: '上海站', price: 200, rent: 25, owner: null },
      { type: 'property', name: '锦江区', price: 180, rent: 14, owner: null },
      { type: 'chance', name: '机会', description: '抽取一张机会卡' },
      { type: 'property', name: '武侯区', price: 180, rent: 14, owner: null },
      { type: 'property', name: '青羊区', price: 200, rent: 16, owner: null },
      { type: 'free-parking', name: '免费停车', description: '休息一下' },
      { type: 'property', name: '江岸区', price: 220, rent: 18, owner: null },
      { type: 'chance', name: '机会', description: '抽取一张机会卡' },
      { type: 'property', name: '武昌区', price: 220, rent: 18, owner: null },
      { type: 'property', name: '汉阳区', price: 240, rent: 20, owner: null },
      { type: 'transport', name: '武汉站', price: 200, rent: 25, owner: null },
      { type: 'property', name: '越秀区', price: 260, rent: 22, owner: null },
      { type: 'property', name: '天河区', price: 260, rent: 22, owner: null },
      { type: 'utility', name: '自来水公司', price: 150, rent: 15, owner: null },
      { type: 'property', name: '海珠区', price: 280, rent: 24, owner: null },
      { type: 'go-to-jail', name: '进监狱', description: '直接去监狱' },
      { type: 'property', name: '和平区', price: 300, rent: 26, owner: null }
    ];
  },
  
  /**
   * 初始化机会卡数据
   * @returns {Array} 机会卡数据
   */
  initChanceCards() {
    return [
      // 金钱相关
      { 
        type: 'money',
        title: '意外收获', 
        description: '你中了彩票，获得100元', 
        actions: [{ text: '领取奖金', action: 'collect', amount: 100 }] 
      },
      { 
        type: 'money',
        title: '医疗费', 
        description: '你生病了，支付50元医疗费', 
        actions: [{ text: '支付', action: 'pay', amount: 50 }] 
      },
      { 
        type: 'money',
        title: '生日快乐', 
        description: '今天是你的生日，每位玩家送你20元', 
        actions: [{ text: '收礼物', action: 'birthday', amount: 20 }] 
      },
      // 移动相关
      { 
        type: 'movement',
        title: '前进', 
        description: '前进3格', 
        actions: [{ text: '前进', action: 'move', steps: 3 }] 
      },
      { 
        type: 'movement',
        title: '后退', 
        description: '后退2格', 
        actions: [{ text: '后退', action: 'move', steps: -2 }] 
      },
      // 特殊事件
      { 
        type: 'special',
        title: '免费维修', 
        description: '你的所有地产获得免费维修，每处地产增值50元', 
        actions: [{ text: '接受维修', action: 'propertyBonus', amount: 50 }] 
      }
    ];
  }
};